fix(kona): use BTreeMap for deterministic JSON serialization in interop host#19906
Open
fix(kona): use BTreeMap for deterministic JSON serialization in interop host#19906
Conversation
…op host Replace HashMap with BTreeMap for DependencySet.dependencies and read_rollup_configs return type. HashMap iteration order is randomized per-process in Rust, so when kona-host serializes these maps as JSON preimages for the cannon VM, two separate kona-host processes (test helper vs challenger) can produce different byte sequences for the same data. This causes cannon VM state divergence, making the challenger disagree with the test's claims and step at the wrong trace index — without uploading the required preimage. The fix ensures deterministic key ordering via BTreeMap, so all kona-host processes produce identical JSON serialization regardless of process-level hash seeds. Fixes #19892 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
I will admit, I went to bed and left Claude running. My earlier hands on session with Claude failed to find it so I just told it to run the test 100 times to verify any change actually works. It spent about 45 minutes thinking about it and 11 hours rerunning tests... |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #19906 +/- ##
===========================================
+ Coverage 75.6% 75.8% +0.1%
===========================================
Files 195 489 +294
Lines 11348 61816 +50468
===========================================
+ Hits 8581 46859 +38278
- Misses 2623 14957 +12334
+ Partials 144 0 -144
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HashMapwithBTreeMapforDependencySet.dependenciesandread_rollup_configsreturn type in kona's interop hostRoot Cause
Rust's
HashMapiteration order is randomized per-process via hash seeds. When kona-host serializesDependencySetand rollup configs as JSON preimages for the cannon VM, two separate kona-host processes (test helper vs challenger) can produce different byte sequences for the same logical data:These different bytes get read into MIPS memory inside the cannon VM, producing different state hashes from that point forward. This causes the challenger to disagree with the test's claims, attack instead of defend, and step at a trace index that has no preimage data — so the preimage never gets uploaded to the oracle, and
WaitForPreimageInOracletimes out.Evidence
dencies":{"90020→ one has0":{},"900201"and the other has1":{},"900200")Test plan
develop-fault-proofsworkflow passesFixes #19892
🤖 Generated with Claude Code